package org.rabbitmq.test.controller;

import org.rabbitmq.test.vo.SendMsgDto;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: Spring_RabbitMQ_Test
 * @author: chen yizhen
 * @create: 2025-03-11 14:00
 **/
@RestController
public class sendMessageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @PostMapping("/sendMsg")
    public void sendMsg(){
        rabbitTemplate.convertAndSend("test.exchange",
                "test.routing.key",new SendMsgDto("Chen Yizhen","123456"));
    }

    @PostMapping("/overTime")
    public void sendOverTime(){
        rabbitTemplate.convertAndSend("test.send.exchange",
                "test.send.routing-key",
                new SendMsgDto("Liu MengYi", "123456"));
    }
}
